home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / ssavwin.exe / ELLPSAVR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-04-29  |  2.2 KB  |  56 lines

  1. {****************************************************************************
  2. *                                                                           *
  3. *  EllpSavr.pas: Plug-in animation module for SSaveDem.pas                  *
  4. *                                                                           *
  5. *  Rev. 0.1   19.4.93   MK  IR                                              *
  6. *                                                                           *
  7. ****************************************************************************}
  8.  
  9. { Name for this Screen Saver - shows up in Control Panel: }
  10. {$D SCRNSAVE Ellipses }
  11.  
  12. const AppName: PChar = 'Screen Saver.Ellipses' ;
  13.  
  14. type
  15.   PMySaverWin = ^TMySaverWin;
  16.   TMySaverWin = Object(TScSaverWin)
  17.     procedure DoTheShow; virtual;
  18.   end;
  19.  
  20. {****************************************************************************
  21. *                                                                           *
  22. *              T M y S a v e r W i n . D o T h e S h o w                    *
  23. *                                                                           *
  24. *  Paints four ellipses around the screen center (clover-like).             *
  25. *                                                                           *
  26. ****************************************************************************}
  27.  
  28. procedure TMySaverWin.DoTheShow ;
  29.  
  30. var TheDC: hDC;
  31.     NewBrush, OldBrush: hBrush;
  32.     x,y,zx,zy,sx,sy: integer;
  33.  
  34. begin
  35.  
  36. TheDC := TestHandle (GetDC (hWindow));
  37.  
  38. NewBrush := TestHandle (CreateSolidBrush          { create random brush }
  39.         ({GetNearestColor (TheDC,}rgb(random(256),random(256), random(256)))){)};
  40. OldBrush := TestHandle (SelectObject (TheDC, NewBrush));
  41.  
  42. zx := GetSystemMetrics (SM_CXSCREEN) ;
  43. zy := GetSystemMetrics (SM_CYSCREEN) ;
  44. randomize;
  45. sx := random (zy div 2);               { get a random size }
  46. sy := random (zy div 2);
  47. for x := 0 to 1 do                   { paint four ellipses }
  48.    for y := 0 to 1 do
  49.       Ellipse (TheDC, zx div 2, zy div 2, sx+x*(zx-2*sx), sy+y*(zy-2*sy));
  50.  
  51. TestHandle (SelectObject (TheDC, OldBrush));
  52. DeleteObject (NewBrush);
  53. ReleaseDC (hWindow, TheDC);
  54. end; { DoTheShow }
  55.  
  56.